#include <iostream>
using namespace std;
#include "animal.h"
#include <cstring>
#include <vector>

class Trainer{
private:
	vector<Animal*> animals;
public:
	Trainer();
	void addAnimal(Animal* animal);
	void removeAnimal(Animal* animal);

	void displayAll() const;
};
Trainer::Trainer()
{
}

void Trainer::addAnimal(Animal* animal)
{
/*
	if(count >= 20) return ;
	animals[count++] = animal;	
*/
	animals.push_back(animal);
}


void Trainer::removeAnimal(Animal* animal)
{
	
	for(vector<Animal*>::iterator it = animals.begin(); it != animals.end(); ++it){
		if(*it == animal){
			animals.erase(it);
			return ;
		}
	}
/*
	for(int i = 0; i < count; i++){
		if(animals[i] == animal){
			animals[i] = animals[count - 1];
			count--;
		}
	}
*/
}


void Trainer::displayAll() const
{
/*
	for(int i = 0; i < count; i++){
		animals[i]->display();
	}
*/
	for(vector<Animal*>::const_iterator it = animals.cbegin(); it != animals.cend(); it++){
		(*it)->display();
	}
}


int main(int argc, char **argv)
{
	Lion lion;
	Tiger tiger;
	Elephant elephant;

	Trainer trainer;
	trainer.addAnimal(&lion);
	trainer.addAnimal(&tiger);
	trainer.addAnimal(&elephant);

	trainer.displayAll();
	cout << "-------------------------------\n";
	trainer.removeAnimal(&lion);
	trainer.displayAll();

	return 0;
}
